function getUserInfo(pageName){
    $.ajax({
        url:"login",
        type:"get",
        success:function(user){
            if(user.id && user.id >= 0){
                //展示用户信息
                showUserInfo(pageName);
            }else{
                //跳转到登录界面
                location.assign("index.html");
            }
        }
    })
}
function showUserInfo(pageName){
    var url ;
    if(pageName == "list"){
        url = "user";
    }else{
        url = "user"+location.search;
    }

    $.ajax({
        type:"get",
        url :url,
        success:function(user){
            console.log(user.userName);
            document.querySelector(".left .card h3").innerHTML = user.userName;
            document.querySelector(".left .card a").href = user.githubUrl;
             //如果登录用户和作者是同一个人, 添加删除链接
             if(user.isYourBlog && user.isYourBlog == 1){
                var nav =document.querySelector(".nav");
                var a = document.createElement("a");
                a.className = "nav_span";
                a.innerHTML = "删除";
                a.href = "delete"+location.search;
                nav.insertBefore(a,nav.children[5]);
             }
        }
    })
}
